package com.zr.bookcorner.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.zh.baselibrary.base.BaseRecyclerAdapter;
import com.zh.baselibrary.utils.BitmapHelp;
import com.zh.model.manager.BookInfo;
import com.zr.bookcorner.R;

import java.util.List;

public class BorrowReturnDetailAdapter extends BaseRecyclerAdapter<BookInfo> {
    public BorrowReturnDetailAdapter(List<BookInfo> mData) {
        super(mData);
    }

    @Override
    protected int getLayoutId(int viewType) {
        return R.layout.item_book;
    }

    @Override
    protected void bindData(BaseViewHolder holder, int position, BookInfo info) {
        BitmapHelp.display((ImageView) holder.getView(R.id.iv_url), info.getImageUrl(), false, R.mipmap.cover);
        setItemText(holder.getView(R.id.tv_book_name),info.getBookName());

            if (info.getStatus() == 1 || info.isBorrow())
                holder.getView(R.id.iv_statu).setVisibility(View.GONE);
            else {
                holder.getView(R.id.iv_statu).setVisibility(View.VISIBLE);
                if (info.getStatus() == 0) {
                    ((ImageView) holder.getView(R.id.iv_statu)).setImageDrawable(mContext.getResources().getDrawable(R.mipmap.status_on));
                } else if (info.getStatus() == 4) {
                    ((ImageView) holder.getView(R.id.iv_statu)).setImageDrawable(mContext.getResources().getDrawable(R.mipmap.status_borrow));
                } else if (info.getStatus() == 5) {
                    ((ImageView) holder.getView(R.id.iv_statu)).setImageDrawable(mContext.getResources().getDrawable(R.mipmap.status_return));
                } else if (info.getStatus() == 6) {
                    ((ImageView) holder.getView(R.id.iv_statu)).setImageDrawable(mContext.getResources().getDrawable(R.mipmap.status_return6));
                }
            }
    }
}
